package com.dona.imsidetector.bean;

import com.dona.imsidetector.db.entity.ListItem;
import com.dona.imsidetector.utils.IMSIUtil;

import java.util.Date;

public class ImsiBean {

    private String imsiAddr;
    private Float power;
    private Integer frequency;
    private Date createDate;
    private String isp; // 运营商
    private String province; // 运营商所在的省
    private String city; // 运营商所在的省的市
    private Integer deviceId;
    private Integer count = 0;
    private Integer isWhite = -1; // 0:黑名单 1：白名单 -1：初始化

    public ImsiBean(){}

    public ImsiBean(ListItem item){
        imsiAddr = item.getImsiAddr();
        power = null;
        frequency = null;
        createDate = item.getCreateTime();
        isp = item.getIspDesc();
        province = item.getProvince();
        city = item.getCity();
        deviceId = null;
        isWhite = item.getIsWhite();
    }

    public ImsiBean(String imsiAddr, Float power,Integer frequency,Integer deviceId) {
        this.imsiAddr = imsiAddr;
        this.power = power;
        this.frequency = frequency;
        this.createDate = new Date();
        this.deviceId = deviceId;
        this.isp = IMSIUtil.getISPbyImsi(imsiAddr);
    }

    public Integer getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(Integer deviceId) {
        this.deviceId = deviceId;
    }

    public String getImsiAddr() {
        return imsiAddr;
    }

    public void setImsiAddr(String imsiAddr) {
        this.imsiAddr = imsiAddr;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date date) {
        this.createDate = date;
    }

    public Float getPower() {
        return power;
    }

    public void setPower(Float power) {
        this.power = power;
    }

    public Integer getFrequency() {
        return frequency;
    }

    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }

    public String getIsp() {
        return isp;
    }

    public void setIsp(String isp) {
        this.isp = isp;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Integer getIsWhite() {
        return isWhite;
    }

    public void setIsWhite(Integer isWhite) {
        this.isWhite = isWhite;
    }

    public String getImsiInfo(){
        StringBuilder sb = new StringBuilder(this.imsiAddr + " ");
        if(null != isp){
            sb.append(isp);
        }
        if(null != province){
            sb.append(province);
        }
        return sb.toString();
    }

    public String getLocation(){
        StringBuilder sb = new StringBuilder("");
        if(null != province){
            sb.append(province);
        }
        if(null != isp){
            sb.append(isp);
        }

        return sb.toString();
    }

    @Override
    public String toString() {
        return "ImsiBean{" +
                "imsiAddr='" + imsiAddr + '\'' +
                ", power=" + power +
                ", createDate=" + createDate +
                '}';
    }
}
